<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="css/lib/bootstrap.min.css"/>
		<script src="js/lib/jquery-1.11.0.js"></script>
		<script src="js/lib/bootstrap.min.js"></script>
		<script src="js/lib/vue.min.js"></script>
		<script src="js/lib/vue-resource.js"></script>
		<script src="js/base.js" type="text/javascript" charset="utf-8"></script>
		<style>
		table td:nth-child(even) {
			width:160px;
		}
		table tr:nth-child(even) {
			background-color:#ffffff;
		}
		input{
			width:280px;
		}
		span{
			color:red;
		}
		</style>
	</head>
	<body>
		<div class="" id="box">
			<div id="sho"></div>
			<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
				<table class="table table-hover">
					<tbody>
					<tr>
						<th colspan="8">品牌信息：</th>
					</tr>
					<tr class="text-center" style="font-size:15px;background:rgb(0, 122, 255);color:#fff">
						<td>品牌名称</td>
						<!-- <td>品牌编号</td> -->
						<td>等级</td>
						<td>自动升级状态</td>
						<td>自动升级人数</td>
						<!--<td>操作</td>-->
					</tr>
					<tr v-for="li in list" id="show" class="text-center">
						<td class="show1"></td>
						<!-- <td id="show2">{{li.brandId}}</td> -->
						<td id="show3">{{li.grade}}</td>
						<td id="show4">{{li.status | todo1}}</td>
						<td id="show5">{{li.peopleNum}}</td>
						<!--<td><button id="btn" v-on:click="add(msg)">变更</button></td>-->
					</tr>
					<tr>
						<td colspan="8" id="show01" class="text-center" style="display:none;">
						</td>
					</tr>
					</tbody>
				</table>
			</div>
		<!---->
		<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
			<table class="table table-hover">				
				<tbody>
					<tr>
						<th colspan="6">设置分享自动升级的人数和开启状态:</th>
					</tr>
					<tr style="display:none;">
						<td style="width:120px"/>设置贴牌:</td>
						<td colspan="6">
							<input id="bid" v-model='bid' class="form-control" type="text" style="width:280px;display:inline-block"/>
							<span>（*贴牌名称）</span>
						</td>								
					</tr>
					<tr>
						<td style="width:120px"/>设置人数:</td>
						<td colspan="6">
							<input id="num" v-model="num" class="form-control" type="text" placeholder="例如:10" style="width:280px;display:inline-block"/>
							<span>（*分享多少个人能升级）</span>
						</td>								
					</tr>
					<tr>
						<td style="width:120px"/>设置等级:</td>
						<td colspan="6">
							<input id="grade" v-model="grade" class="form-control" type="text" placeholder="产品级别，例如：1" style="width:280px;display:inline-block"/>
							<span>（*设置对应的产品的等级）</span>
						</td>								
					</tr>
					<tr>
						<td>
							是否开启分享升级功能：
						</td>
						<td colspan="6">
							<select name="" id="t" v-on:change="t" class="form-control" style="width:280px;display:inline-block;">
								<option value="0">启用</option>
								<option value="1">不启用</option>
							</select>
							<span id="s"></span>
						</td>
					</tr>
					
					<tr>
						<td colspan="7">
							<button id="btn" v-on:click="btn()" class="btn btn-danger" style="display:block;margin:0 auto">确认修改</button>
						</td>					
					</tr>
				</tbody>
			</table>		
		</div>
		<script>
			$(function(){				
				/*自定义过滤器*/
                Vue.filter("todo1",function(value){
                    if(value == 1){
                        return value = "不启用"
                    }
                    if(value == 0){
                        return value = "启用"
                    }
                });
                Vue.filter("todo2",function(value){
                    if(value == 1){
                        return value = "赚道钱包"
                    }
                    if(value == 3){
                        return value = "雷闪付"
                    }
                   
                });
                new Vue({
					el:"#box",
					data:{
					    list:[],
						msg:"",
						bid:"",
						num:"",
						grade:""
					},
					created:function(){
						var brandid = sessionStorage.getItem(key=3);
					    var brandname = sessionStorage.getItem(key=100);
					    var msg = brandname;
					    console.log(msg);
					    $('.show1').text(msg)
                        var p5 = brandid;
                        console.log(p5)
                        this.$http.post(window.baseUrl+"user/auto/upgrade/Config/brand/query",{brand_id:p5},{emulateJSON:true}).then(
                            function (res){
                                console.log(res)
                                console.log(res.data.result)
								this.list = res.data.result;
								console.log(this.list)
                            },
							function (res) {
                                console.log(res)
                               
                            }
                        );                             
            },
					methods:{			
						t:function(){
								var t = $('#t').find('option:selected').text()
								$('#s').html(t)
						},
						/*添加升级配置*/
						btn:function(){
							var id = sessionStorage.getItem(key=3);
							/*接口前缀*/
                            var url01 = "http://192.168.1.120:80";
                            var url02 = window.baseUrl;
                            var tag = $('#t').val();
                            var num = $('#num').val();
                            var grade = $('#grade').val();

                            console.log(id);
                            var brandid = id
                            console.log(brandid)
                            var data = {
                                    brand_id:brandid,
                                    grade:grade,
									people_num:num,
									status:$('#t').val()
                                };
                                console.log(data)
                            $.ajax({
                                type:"post",
                                url:url02+"user/auto/upgrade/Config/add",
                                async:true,
                                data:data,
                                datatype:"json",
                                success:function(data){
                                    alert("数据保存成功！")
                                    console.log(data)
									window.location.href = "会员自动更新.html"
                                },
                                error:function(data){
                                    alert("数据保存失败！")
                                    console.log(data)
                                }
                            });
						}
					}
				})
			})
		</script>	
	</body>
</html>


